package games.distetris.domain;
//Download by http://www.codefans.net
import android.graphics.Color;

public class PieceConstants {
	public static int FREEBLOCK = 0;
	public static int PIVOTBLOCK = 2;
	public static int PIECEBLOCK = 1;
	public static int PIECESIZE = 5;
	private static int sc = 0;

	public static byte[/*Type*/][/*Rotation*/][/*Horitz Blocks*/][/*Vert Blocks*/] cPieces =
	{
	// Square
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 0, 0, 0}
	    }
	   },

	// I
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 1, 2, 1, 1},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0}, 
	    {0, 0, 2, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 1, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {1, 1, 2, 1, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 1, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 2, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    }
	   }
	  ,
	// L
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 2, 0, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 1, 2, 1, 0},
	    {0, 1, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 1, 1, 0, 0},
	    {0, 0, 2, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 1, 0},
	    {0, 1, 2, 1, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    }
	   },
	// L mirrored
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 2, 0, 0},
	    {0, 1, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 1, 0, 0, 0},
	    {0, 1, 2, 1, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 2, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 1, 2, 1, 0},
	    {0, 0, 0, 1, 0},
	    {0, 0, 0, 0, 0}
	    }
	   },
	// Z
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 1, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 1, 2, 0, 0},
	    {0, 0, 1, 1, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 1, 2, 0, 0},
	    {0, 1, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 1, 1, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    }
	   },
	// Z mirrored
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 0, 1, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 1, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 1, 0, 0, 0},
	    {0, 1, 2, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 1, 0},
	    {0, 1, 2, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    }
	   },
	// T
	  {
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 2, 1, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0},
	    {0, 1, 2, 1, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 1, 2, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 0, 0, 0, 0}
	    },
	   {
	    {0, 0, 0, 0, 0},
	    {0, 0, 1, 0, 0},
	    {0, 1, 2, 1, 0},
	    {0, 0, 0, 0, 0},
	    {0, 0, 0, 0, 0}
	    }
	   }
	};
	
	public static byte[/*Type*/][/*Rotation*/][/*position*/] startPos =  
		 {  
		 /* Square */  
		   {  
		     {2, -3},  
		     {-2, -3},  
		     {-2, -3},  
		     {-2, -3}  
		    },  
		 /* I */  
		   {  
		     {2, -2},  
		     {-2, -3},  
		     {-2, -2},  
		     {-2, -3}  
		    },  
		 /* L */  
		   {  
		     {3, -2},  
		     {-2, -3},  
		     {-2, -3},  
		     {-2, -2}  
		    },  
		 /* L mirrored */  
		   {  
		     {3, -2},  
		     {-2, -2},  
		     {-2, -3},  
		     {-2, -3}  
		    },  
		 /* N */  
		   {  
		     {2, -2},  
		     {-2, -3},  
		     {-2, -3},  
		     {-2, -2}  
		    },  
		 /* N mirrored */  
		   {  
		     {2, -2},  
		     {-2, -3},  
		     {-2, -3},  
		     {-2, -2}  
		    },  
		 /* T */  
		   {  
		     {2, -2},  
		     {-2, -3},  
		     {-2, -3},  
		     {-2, -2}  
		    },  
		 };  
	
	public static int npieces = cPieces.length;
	private static int[] defcolors = {Color.RED,Color.BLUE,Color.YELLOW,Color.GREEN,Color.MAGENTA,Color.CYAN,Color.GRAY,Color.CYAN,Color.WHITE}; 
	
	public static int randomColor() {
		int x = (int) (Math.random()*100)%defcolors.length;
		return defcolors[x];
	}
	
	/**
	 * Returns a defined color in order
	 * @return
	 */
	public static int nextColor(){
		int x = defcolors[sc];
		sc++;
		if(sc>=defcolors.length) sc = 0;
		return x;
	}
}
